//
// Created by lm379 on 25-3-18.
//
#include <iostream>
#define maxSize 100
using namespace std;

bool compare(const char left, const char right) {
    switch (left) {
        case '{':
            if (right == '}')
                return true;
            break;
        case '[':
            if (right == ']')
                return true;
            break;
        case '(':
            if (right == ')')
                return true;
            break;
        default:
            break;
    }
    return false;
}

bool isParenthesisMatched(char str[]) {
    char stack[maxSize];
    int top = -1;
    int i = 0;
    while (str[i] != '\0') {
        if (str[i] == '(' || str[i] == '[' || str[i] == '{') {
            stack[++top] = str[i++];
        }
        if (str[i] == ')' || str[i] == ']' || str[i] == '}') {
            if (top == -1 || !compare(stack[top--],str[i++])) {
                return false;
            }
        }
    }
    if (top != -1) {
        return false;
    }
    return true;
}

int main() {
    char str[] = "[(({}))][[(())]]{}";
    if (isParenthesisMatched(str)) {
        cout << "true";
    } else {
        cout << "false";
    }
    cout << endl;
    return 0;
}